// 局部仓库,存储用户页面的token信息
import { saveToken, getToken, getRefreshToken, saveRefreshToken, clearToken, clearRefreshToken } from '@/utlis/storage'
const state = {
  tokenInfo: getToken(),
  refreshToken: getRefreshToken()
}
const mutations = {
  setTokenInfo (state, newTokenInfo) {
    state.tokenInfo = newTokenInfo
    saveToken(newTokenInfo)
  },
  setRefreshToken (state, newTokenInfo) {
    state.refreshToken = newTokenInfo
    saveRefreshToken(newTokenInfo)
  },
  removeRefreshToken (state) {
    state.refreshToken = ''
    clearRefreshToken()
  },
  removeToken (state) {
    state.tokenToken = ''
    clearToken()
  }
}
export default {
  namespaced: true,
  state,
  mutations
}
